firm = firm[firm$l != 0 ]
firm = firm[firm$l != 0 ,]
View(firm)
l = length(firm[,1])
source('~/Desktop/CEO TEst.R')
library(ineq)
hist(payroll)
hist(log(payroll))
hist(log(payroll), breaks  = 100)
ineq(payroll)
max(payroll)/mean(payroll)
View(firm)
p = 1.02^exp
pay = cumprod(p)
firm = data.frame(l,pay)
View(firm)
source('~/Desktop/CEO TEst.R')
max(payroll)/mean(payroll)
ineq(payroll)
source('~/Desktop/CEO TEst.R')
g = ineq(payroll)
CEO = max(payroll)/mean(payroll)
source('~/Desktop/CEO TEst.R')
View(firm)
s = 1.1^exp
l = b*(s)^exp
l = floor(l)
p = 1.05^exp
pay = cumprod(p)
mu = log(pay)
sigma = 0.2
View(firm)
l = b*(1/s)^exp
l = floor(l)
p = 1.05^exp
pay = cumprod(p)
mu = log(pay)
sigma = 0.2
firm = data.frame(l,pay)
source('~/Desktop/CEO TEst.R')
View(firm)
plot(l)
exp = 0:20
b = 10^5
s = 1.1^exp
l = b*(1/s)^exp
l = floor(l)
plot(l)
g = ineq(payroll)
CEO = max(payroll)/mean(payroll)
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
plot(l)
View(firm)
plot(firm$l)
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
source('~/Desktop/CEO TEst.R')
plot(pay)
plot(log(pay)
plot(log(pay))
plot(log(pay))
View(firm)
library(ineq)
x = c(31321, 1611)
ineq(x)
between = c(31321, 1611)
ineq(between)
gini.between = ineq(between)
gini.within = mean(c(0.64,0.48))
gini.between/gini.within
between = c(38328, 3571)
gini.between = ineq(between)
gini.within = mean(c(0.64,0.48))
gini.between/gini.within
x = rlnorm(10^6, 10, 2)
p = 10^6*0.01
x = sort(x)
y = head(x, p)
hist(y)
y = x[p, 2*p]
y = x[p:2*p]
y = x[p:(2*p)]
hist(y)
library(ineq)
ineq(y)
y = x[(3p):(4*p)]
y = x[(3*p):(4*p)]
ineq(y)
hist(y)
ineq(y)
y = x[(99*p):(100*p)]
ineq(y)
hist(y)
ineq(y)
y = x[(80*p):(81*p)]
ineq(y)
hist(y)
hist(log(y))
y = x[(95*p):(95*p)]
ineq(y)
y = x[(95*p):(96*p)]
ineq(y)
hist(log(y))
y = x[(98*p):(99*p)]
ineq(y)
hist(log(y))
y = x[(99*p):(100*p)]
ineq(x)
x = rlnorm(10^6, 10, 1)
x = sort(x)
ineq(x)
p = 10^6*0.01
y = x[(99*p):(100*p)]
ineq(y)
hist(log(y))
y = x[(98*p):(99*p)]
ineq(y)
hist(log(y))
y = tail(x, p)
ineq(y)
hist(log(y))
hist(log(y), breaks = 100)
mean(y)
sd(y)/mean(y)
y = x[(98*p):(99*p)]
mean(y)
sd(y)/mean(y)
hist(y, breaks = 100)
y = x[(90*p):(91*p)]
ineq(y)
mean(y)
sd(y)/mean(y)
hist(y, breaks = 100)
ineq(y)
ineq(y)
y = x[(70*p):(71*p)]
ineq(y)
mean(y)
sd(y)/mean(y)
hist(y, breaks = 100)
x, breaks = 100)
hist(100), breaks = 100)
hist(x, breaks = 100)
hist(x, breaks = 100, xlim = c(0, 10^5))
hist(x, breaks = 1000, xlim = c(0, 10^5))
p = quantile(x, probs = seq(0,1, length.out = 100))
p
p = data.frame(quantile(x, probs = seq(0,1, length.out = 100)))
View(p)
p = data.frame(quantile(x, probs = seq(0,1, 0.01)))
View(p)
ineq(x)
p = quantile(x, probs = seq(0,1, 0.01))
test = ineq(p)
test = ineq(p[1:99])
ineq(p[1:99])
ineq(x)
x = rlnorm(10^6, 10, 1)
x = sort(x)
ineq(x)
p = quantile(x, probs = seq(0,1, 0.01))
ineq(p[1:99])
p
p = quantile(x, probs = seq(0,1, 0.1))
ineq(p[1:99])
ineq(p[1:10])
p
install.packages("XML")
install.packages("XML")
library(XML)
test = xmlToList("Test.xml")
test = xmlToList("Test.XML")
1+NA
x = NA
y = 10
x+y
library(ineq)
x = rlnorm(10^5, 10, 0.8)
ineq(x)
plnorm(10, 10, 0.8)
qlnorm(10, 10, 0.8)
?lnorm
?qlnorm
plnorm(10, 10, 0.8)
qlnorm(0.1, 10, 0.8)
qlnorm(0.9, 10, 0.8)
qlnorm(0.25, 10, 0.8)
mu = log(36)
sd = sqrt(2*(log(48) - mu))
sigma = sqrt(2*(log(48) - mu))
library(NORMT3)
erf(sigma/2)
erf(sigma/2)
year = 1994:2015
l = length(year)
url = "http://www.census.gov/data/tables/time-series/demo/income-poverty/cps-pinc/pinc-06.2015.html"
final = NULL
t = year[i]
i = 1
t = year[i]
t.sub = as.character(t)
url.year = gsub("2015", t, url)
doc = htmlParse(url.year)
library(readr)
library(XML)
doc = htmlParse(url.year)
links <- xpathSApply(doc, "//a/@href")
links
install.packages("jpeg")
install.packages("tcltk2")
install.packages("jpeg")
library(tcltk2)
library(jpeg)
library(zoo)
setwd("~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Grund")
jpegfile<-tk_choose.files(caption="Grund_1.jpg")
jpegfile<-tk_choose.files(caption="JPEG FILE")
(outfile<-paste(unlist(strsplit(jpegfile,"\\."))[1],".txt",sep=""))
ReadAndCal = function(fname)
{
ReadImg(fname)
calpoints <- locator(n=4,type='p',pch=4,col='blue',lwd=2)
return(calpoints)
}
ReadImg = function(fname)
{
img <- readJPEG(fname)
op <- par(mar=c(0,0,0,0))
on.exit(par(op))
plot.new()
rasterImage(img,0,0,1,1)
}
DigitData = function(col='red',type='p',...)
{
type <- ifelse(type=='b','o',type)
type <- ifelse(type%in%c('l','o','p'),type,'p')
locator(type=type,col=col,...)
}
Calibrate = function(data,calpoints,x1,x2,y1,y2)
{
x 		<- calpoints$x[c(1,2)]
y 		<- calpoints$y[c(3,4)]
cx <- lm(formula = c(x1,x2) ~ c(x))$coeff
cy <- lm(formula = c(y1,y2) ~ c(y))$coeff
data$x <- data$x*cx[2]+cx[1]
data$y <- data$y*cy[2]+cy[1]
Calibrate = function(data,calpoints,x1,x2,y1,y2)
{
x 		<- calpoints$x[c(1,2)]
y 		<- calpoints$y[c(3,4)]
cx <- lm(formula = c(x1,x2) ~ c(x))$coeff
cy <- lm(formula = c(y1,y2) ~ c(y))$coeff
data$x <- data$x*cx[2]+cx[1]
data$y <- data$y*cy[2]+cy[1]
return(as.data.frame(data))
}
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Grund/Digitize.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Grund/Digitize.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Grund/Digitize.R')
library(tcltk2)
library(jpeg)
library(zoo)
#load imagefile
jpegfile<-tk_choose.files(caption="JPEG FILE")
(outfile<-paste(unlist(strsplit(jpegfile,"\\."))[1],".txt",sep=""))
#digitize functions
ReadAndCal = function(fname)
{
ReadImg(fname)
calpoints <- locator(n=4,type='p',pch=4,col='blue',lwd=2)
return(calpoints)
}
ReadImg = function(fname)
{
img <- readJPEG(fname)
op <- par(mar=c(0,0,0,0))
on.exit(par(op))
plot.new()
rasterImage(img,0,0,1,1)
}
DigitData = function(col='red',type='p',...)
{
type <- ifelse(type=='b','o',type)
type <- ifelse(type%in%c('l','o','p'),type,'p')
locator(type=type,col=col,...)
}
Calibrate = function(data,calpoints,x1,x2,y1,y2)
{
x 		<- calpoints$x[c(1,2)]
y 		<- calpoints$y[c(3,4)]
cx <- lm(formula = c(x1,x2) ~ c(x))$coeff
cy <- lm(formula = c(y1,y2) ~ c(y))$coeff
data$x <- data$x*cx[2]+cx[1]
data$y <- data$y*cy[2]+cy[1]
return(as.data.frame(data))
}
(cal = ReadAndCal(jpegfile))
# https://www.r-bloggers.com/digitizing-jpeg-graphs-in-r/
library(tcltk2)
library(jpeg)
library(zoo)
#load imagefile
jpegfile<-tk_choose.files(caption="JPEG FILE")
(outfile<-paste(unlist(strsplit(jpegfile,"\\."))[1],".txt",sep=""))
#digitize functions
ReadAndCal = function(fname)
{
ReadImg(fname)
calpoints <- locator(n=4,type='p',pch=4,col='blue',lwd=2)
return(calpoints)
}
ReadImg = function(fname)
{
img <- readJPEG(fname)
op <- par(mar=c(0,0,0,0))
on.exit(par(op))
plot.new()
rasterImage(img,0,0,1,1)
}
DigitData = function(col='red',type='p',...)
{
type <- ifelse(type=='b','o',type)
type <- ifelse(type%in%c('l','o','p'),type,'p')
locator(type=type,col=col,...)
}
Calibrate = function(data,calpoints,x1,x2,y1,y2)
{
x 		<- calpoints$x[c(1,2)]
y 		<- calpoints$y[c(3,4)]
cx <- lm(formula = c(x1,x2) ~ c(x))$coeff
cy <- lm(formula = c(y1,y2) ~ c(y))$coeff
data$x <- data$x*cx[2]+cx[1]
data$y <- data$y*cy[2]+cy[1]
return(as.data.frame(data))
}
(cal = ReadAndCal(jpegfile))
(data.points = DigitData(col = 'red'))
setwd("~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Grund")
setwd("~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Grund")
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Grund/Parametric Fit.R')
write_csv(output, "Grund Level Results.csv")
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Grund/Parametric Fit.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Grund/Parametric Fit.R')
gini
dir = dirname(rstudioapi::getActiveDocumentContext()$path)
workspace = gsub("Model", "Raw Data", dir)
setwd(workspace)
dir = dirname(rstudioapi::getActiveDocumentContext()$path)
dir
dir = dirname(rstudioapi::getActiveDocumentContext()$path)
workspace = gsub("Model", "Raw Data", dir)
setwd(workspace)
O = read_csv("Mueller.csv")
dir = dirname(rstudioapi::getActiveDocumentContext()$path)
workspace = gsub("Model", "Functions", dir)
setwd(workspace)
O = read_csv("Grund Merge.csv")
library(ineq)
library(readr)
library(data.table)
dir = dirname(rstudioapi::getActiveDocumentContext()$path)
workspace = gsub("Model", "Functions", dir)
setwd(workspace)
O = read_csv("Grund Merge.csv")
dir = dirname(rstudioapi::getActiveDocumentContext()$path)
workspace = paste(dir, "/Functions", sep = "")
setwd(workspace)
O = read_csv("Grund Merge.csv")
files = list.files(pattern = "csv")
files = files[files != "Grund Merge.csv"]
fit <- do.call(rbind,lapply(files, read_csv))
fit[, 2:5] = fit[, 2:5]*1000
files = list.files(pattern = "csv")
files = files[files != "Grund Merge.csv"]
fit <- do.call(rbind,lapply(files, read_csv))
files = list.files(pattern = "csv")
files = files[files != "Grund Merge.csv"]
files
fit <- lapply(files, read_csv)
fit <- do.call(rbind,lapply(files, read_csv))
fit <- do.call(rbind,lapply(files, read.csv))
fit
O = read_csv("Grund Merge.csv")
quants <- c(0.05, 0.95)
l = length(O$x)
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Functions/truncnorm.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Functions/FUNCTION MASTER SCRIPT.R')
dir = dirname(rstudioapi::getActiveDocumentContext()$path)
workspace = paste(dir, "/Functions", sep = "")
setwd(workspace)
O = read_csv("Grund Merge.csv")
files = list.files(pattern = "csv")
files = files[files != "Grund Merge.csv"]
fit <- do.call(rbind,lapply(files, read_csv))
fit[, 2:5] = fit[, 2:5]*1000
library(ineq)
library(readr)
library(data.table)
dir = dirname(rstudioapi::getActiveDocumentContext()$path)
workspace = paste(dir, "/Functions", sep = "")
setwd(workspace)
O = read_csv("Grund Merge.csv")
files = list.files(pattern = "csv")
files = files[files != "Grund Merge.csv"]
fit <- do.call(rbind,lapply(files, read_csv))
fit[, 2:5] = fit[, 2:5]*1000
lapply(files, read_csv)
missing = 5 - length(test)
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Functions/lnorm fit.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Functions/lnorm fit.R')
View(fit)
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Functions/FUNCTION MASTER SCRIPT.R')
library(ineq)
library(readr)
library(data.table)
dir = dirname(rstudioapi::getActiveDocumentContext()$path)
workspace = paste(dir, "/Functions", sep = "")
setwd(workspace)
O = read_csv("Grund Merge.csv")
files = list.files(pattern = "csv")
files = files[files != "Grund Merge.csv"]
fit <- do.call(rbind,lapply(files, read_csv))
fit[, 2:5] = fit[, 2:5]*1000
lapply(files, read_csv)
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Functions/weibull.R')
View(fit)
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Functions/FUNCTION MASTER SCRIPT.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Functions/Log logistic.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Functions/Log logistic.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Functions/Log logistic.R')
stopCluster(cl)
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Functions/FUNCTION MASTER SCRIPT.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Occupation/BLS/Functions/sqrt normal.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Functions/sqrt normal.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Functions/sqrt normal.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Functions/sqrt normal.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Functions/FUNCTION MASTER SCRIPT.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Occupation/BLS/Functions/truncnorm.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Occupation/BLS/Functions/truncnorm.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Functions/truncnorm.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Functions/truncnorm.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Functions/truncnorm.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Functions/truncnorm.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Functions/truncnorm.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Functions/truncnorm.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Functions/FUNCTION MASTER SCRIPT.R')
library(ineq)
library(readr)
library(data.table)
dir = dirname(rstudioapi::getActiveDocumentContext()$path)
workspace = paste(dir, "/Functions", sep = "")
setwd(workspace)
O = read_csv("Grund Merge.csv")
files = list.files(pattern = "csv")
files = files[files != "Grund Merge.csv"]
fit <- do.call(rbind,lapply(files, read_csv))
fit[, 2:5] = fit[, 2:5]*1000
library(ineq)
library(readr)
library(data.table)
dir = dirname(rstudioapi::getActiveDocumentContext()$path)
workspace = paste(dir, "/Functions", sep = "")
setwd(workspace)
O = read_csv("Grund Merge.csv")
files = list.files(pattern = "csv")
files = files[files != "Grund Merge.csv"]
fit <- do.call(rbind,lapply(files, read.csv))
fit[, 2:5] = fit[, 2:5]*1000
View(fit)
O.match = do.call("rbind", replicate(length(unique(fit$type)), O, simplify = FALSE))
error  =   rowSums( abs((O.match[ ,3:5] - fit[, 2:4])) , na.rm = T)
O.match = do.call("rbind", replicate(length(unique(fit$type)), O, simplify = FALSE))
error  =   rowSums( abs((O.match[ ,3:5] - fit[, 2:4])) , na.rm = T)
O.match$error = error
O.match = data.table(fit, O.match)
O.match$error[O.match$error == Inf] = 10^10
best = O.match[ , .I[error == min(error, na.rm = T)], by = Level]
View(O)
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Grund Analysis.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Grund Analysis.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Grund Analysis.R')
View(best)
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Grund Analysis.R')
View(best)
View(best)
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Grund Analysis.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Grund Analysis.R')
source('~/Desktop/Empirical Research/Income Distribution/Gini Ratio/Hierarchical Levels/Empirical/Case Studies/Grund/Grund Analysis.R')
